<!DOCTYPE html>
<html lang="zh-cmn-Hans">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>快来和我一起赚钱！</title>
		<style type="text/css">
			body{font-size:1em;color:#940b05;box-sizing:border-box}
			*{margin:0;padding:0}
			input{outline:0}
			.login_bg{width:100%;min-height:100%;text-align:center;background-image:url(others/invite-bg.jpg);background-size:100% auto;background-repeat:no-repeat;background-color:#c1271f;opacity:.9;position:absolute;top:0;left:0;display:flex;flex-direction:column;align-items:center}
			#form{width:80%;text-align:left;margin-top:105vw}
			#form div.passWord,#form div.userName{border:1px solid #940b05;padding:3.5% 0 4% 3%;height:22%;background:#fff}
			input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#9a4d49}
			input:-moz-placeholder,textarea:-moz-placeholder{color:#9a4d49}
			input::-moz-placeholder,textarea::-moz-placeholder{color:#9a4d49}
			input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#9a4d49}
			#form div.passWord.p1{border-bottom:0}
			#form div.userName{border-bottom:0;-webkit-border-top-left-radius:.45em;-webkit-border-top-right-radius:.45em;-moz-border-radius-topleft:.45em;-moz-border-radius-topright:.45em;border-top-left-radius:.45em;border-top-right-radius:.45em}
			#form div.passWord{-webkit-border-bottom-left-radius:.45em;-webkit-border-bottom-right-radius:.45em;-moz-border-radius-bottomleft:.45em;-moz-border-radius-bottomright:.45em;border-bottom-left-radius:.45em;border-bottom-right-radius:.45em}
			#form div.passWord.p1{-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;border-bottom-left-radius:0;border-bottom-right-radius:0}
			#form div.passWord input,#form div.userName input{width:68%;height:80%;border:none;background:0 0;font-size:1em;font-family:"Microsoft YaHei";color:#b3b3b3;letter-spacing:1px;padding-left:2px}
			.login_btn{margin-top:5vw;width:100%;display:block;padding:3% 0;background:#fff;border:0;font-size:1em;font-family:"Microsoft YaHei";color:#940b05;-webkit-box-shadow:#8f9bad 0 0 20px;-moz-box-shadow:#8f9bad 0 0 20px;box-shadow:#8f9bad 0 0 20px;text-align:center;border-radius:.45em}
			#loading{position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0,0,0,.75);color: #fff;display: flex;justify-content: center;align-items: center;font-size: 5vw;font-weight: bold;display:none}
		</style>
		<script src="others/config.js" type="text/javascript" charset="utf-8"></script>
		<script>
			window.onload = function(){
				var $userName = document.getElementsByName("userName")[0],
					$password1 = document.getElementsByName("password1")[0],
					$password = document.getElementsByName("password")[0],
					$login_btn = document.getElementById("zcbtn"),
					$loading = document.getElementById("loading"),
					event = "";	//事件
					
				// PC端 移动端 跳转
				var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
				if (is_mobi) {
					event = "touchend";
				}else{
					event = "click";
				}
				
				//监听
				$login_btn.addEventListener(event,function(){
					if($userName.value.trim()=="" || $password1.value.trim()=="" || $password.value.trim()==""){
						alert("请检查是否有未填项")
						return;
					}
					
					if($password1.value != $password.value){
						alert("两次输入的密码不一致")
						return;
					}
					
					var base64Id = location.search.slice(1);
					
					if(!base64Id || base64Id.trim()==""){
						alert("邀请用户连接非法！")
						return;
					}
					
					//loading
					$loading.style.display = "flex";
					
					var __data = {
						parentId:atob(base64Id),
						username:$userName.value,
						password:$password.value
					}
					
					var xhr = new XMLHttpRequest()
					xhr.timeout = 999999
					xhr.open('POST',__host+"/begin/regist",true)
					xhr.setRequestHeader('Content-Type','application/json')
					xhr.send(JSON.stringify(__data))
					xhr.onreadystatechange = function(){
						if(xhr.readyState==4){
							//hide loading
							$loading.style.display = "none";
							if(xhr.status>=200 && xhr.status<300 || xhr.status==304){
								var res = JSON.parse(xhr.response)
								
								if(res.message){
									alert(res.message)
								}
								
								if(res==200){
									alert("注册成功,请牢记用户名和密码,准备前往APP下载页面！")
									location.href = "https://qianduo.xyz/ticket/html/download/zongxiang.apk";
								}
							}else{
								alert(xhr.status+':服务器请求失败！')
							}
						}
					}
				},false)
			}
		</script>
	</head>
	<body>
		<div class="login_bg">
			<div id="form">
				<div class="userName">
					<lable>用户名：</lable>
					<input type="text" name="userName" placeholder="请输入用户名"/>
				</div>
				<div class="passWord p1">
					<lable>密&nbsp;&nbsp;&nbsp;码：</lable>
					<input type="password" name="password1" placeholder="请输入密码"/>
				</div>
				<div class="passWord">
					<lable>确&nbsp;&nbsp;&nbsp;认：</lable>
					<input type="password" name="password" placeholder="请再次输入密码"/>
				</div>
				<button id="zcbtn" class="login_btn">注&nbsp;&nbsp;册</button>
			</div>
		</div>
		<div id="loading">等待中...</div>
	</body>
</html>
